package viewmodel;

import java.util.ArrayList;
import java.util.List;

import admin.dao.ExamsDAO;

import model.Exams;


public class ExamsDataModel {
	private List<Exams> allExams = new ArrayList<Exams>();
	
	public ExamsDataModel(){
		updateAllExams();
	}
	
	public List<Exams> getAllExams() {
		return allExams;
	}

	public void updateAllExams(){
		this.allExams = ExamsDAO.getAllExams();
	}
	public static List<ExamsEditStatus> convertExamsToEditData(List<Exams> listExams){
		ArrayList<ExamsEditStatus> result = new ArrayList<ExamsEditStatus>();
		for(Exams exams : listExams){
			ExamsEditStatus examsEdit = new ExamsEditStatus(exams, false);
			examsEdit.setLinkQuestionLayout("question_layout.jsp?id="+exams.getMaDe());
			examsEdit.setLinkAddQuestion("question_add_layout.jsp?id="+exams.getMaDe());
			result.add(examsEdit);
		}
		return result;
	}
	public List<ExamsEditStatus> convertExamsToEditData(){
		return ExamsDataModel.convertExamsToEditData(allExams);
	}
}
